namespace Management.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class CreateTableAdminAndRole : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Admins",
                c => new
                    {
                        AdminID = c.Int(nullable: false, identity: true),
                        Accounts = c.String(nullable: false, maxLength: 30),
                        RoleID = c.Int(nullable: false),
                        Password = c.String(nullable: false, maxLength: 256),
                        LoginIP = c.String(),
                        LoginTime = c.DateTime(),
                        CreateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.AdminID)
                .ForeignKey("dbo.Roles", t => t.RoleID, cascadeDelete: true)
                .Index(t => t.RoleID);
            
            CreateTable(
                "dbo.Roles",
                c => new
                    {
                        RoleID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        Created_at = c.DateTime(nullable: false),
                        Updated_at = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.RoleID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Admins", "RoleID", "dbo.Roles");
            DropIndex("dbo.Admins", new[] { "RoleID" });
            DropTable("dbo.Roles");
            DropTable("dbo.Admins");
        }
    }
}
